﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Configuration;
using System.IO;

namespace CloudStorageLight.Core.Tests
{
    [TestClass]
    public class AzureBlobAdapterTest
    {

        private string ConnectionString = ConfigurationManager.AppSettings["blobService.connectionString"];

        [TestMethod]
        public void GetFilesAsyncTest()
        {
            using (var adp = new AzureBlobAdapter("/", "unittest", ConnectionString))
            {
                adp.CreateDirectoryAsync(new BlobDirectory(null,  "/TempFolder/")).Wait();
                var item = new BlobItem(null, "/TempFolder/Work.txt");
                using (var st = new MemoryStream(new byte[] { 32 }))
                {
                    adp.UploadAsync(item, st).Wait();
                }

                var list = adp.GetFilesAsync("/TempFolder/", 0, false).Result;
                Assert.IsTrue(list.Count > 0);
            }

        }
    }
}
